<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog ms-modal-dialog" style="width: 60%">
  <div class="modal-content">
     
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title">添加</h4>
    </div>

    <form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/coupon-batch/create" data-validate="true">

      <div class="modal-body">
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">优惠券模版</label>
          <div class="pull-left" style="width: 30%">
            <select name="couponTemplate" class="select2 form-control select-style"  data-validate="required">
              <option value=""></option>
              <c:forEach var="couponTemplate" items="${persist.couponTemplates}">
                <option value="${couponTemplate.id}" >${couponTemplate.name}</option>
              </c:forEach>
            </select>
          </div>
          
          <label class="col-xs-2 control-label">批次名称</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" name="name" placeholder="请输入批次名称" />
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">本次发放总数</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" name="amount" data-validate="required|number" placeholder="请输入本次发放总数" />
          </div>
          
          <label class="col-xs-2 control-label">截止日类型</label>
          <div class="pull-left" style="width: 30%">
            <select name="expireType" class="form-control select2 select-style" data-validate="required">
              <option value=""></option>
              <c:forEach var="expireType" items="${enums['expireType']}" >
                <option value="${expireType}">${expireType.description}</option>
              </c:forEach>
            </select>
          </div>
        </div>
        
        <div id="effectiveDays" class="form-group ms-form-group">
          <label class="col-xs-2 control-label">固定天数</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" name="effectiveDays" placeholder="请输入固定天数" />
          </div>
        </div>
        
        <div id="effectiveStartDate" class="form-group ms-form-group hide">
          <label class="col-xs-2 control-label">开始日期</label>
          <div class="pull-left" style="width: 50%">
            <div class="input-group date">
              <input type="text" name="effectiveStartDate" class="form-control" />
              <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
            </div>
          </div>
        </div>
        
        <div id="effectivEndDate" class="form-group ms-form-group hide">
          <label class="col-xs-2 control-label">截止日期</label>
          <div class="pull-left" style="width: 50%">
            <div class="input-group date">
              <input type="text" name="effectiveEndDate" class="form-control" />
              <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
            </div>
          </div>
        </div>
        
      </div>

      <div class="modal-footer ms-modal-footer">
        <button type="submit" class="btn ms-btn btn-primary">确定</button>
        <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
      </div>

    </form>

  </div>
</div>
<script>
$(function() {
    $('.date').datetimepicker({
      format: 'yyyy-mm-dd',
      autoclose: true,
      language: 'zh-CN',
      todayBtn: 'linked',
      todayHighlight: true,
      pickerPosition: 'bottom-right',
      minView: 'month'
    });
    
    $('select[name="expireType"]').select2({
      placeholder : '请选择截止日期类型',
      minimumResultsForSearch : -1,
      allowClear : true
    });
    
    $('select[name="couponTemplate"]').select2({
      placeholder : '请选择所属模版',
      minimumResultsForSearch : 5,
      allowClear : true
    });
    
  })

</script>
